fix tidy bugprone-reserved-identifier
authortsteven4 <13596209+tsteven4@users.noreply.github.com>
Sun, 20 Nov 2022 16:35:13 +0000 (09:35 -0700)
committertsteven4 <13596209+tsteven4@users.noreply.github.com>
Sun, 20 Nov 2022 16:35:13 +0000 (09:35 -0700)
this was partially automatic and partially manual.

gbser.cc
gbser.h
gbser_posix.cc
gbser_private.h
gbser_win.cc
wbt-200.cc

index fe787000d1ab61dcd987c515ffcea5ec2ebd8c6b..bda793e52b3efc4dbbe5c693d188c0a3b5ce76ce 100644 (file)
--- a/gbser.cc
+++ b/gbser.cc
@@ -27,7 +27,7 @@
 #include <cstdarg>
 #include <cstdio>
 
-void gbser__db(int l, const char* msg, ...)
+void gbser_db(int l, const char* msg, ...)
 {
   va_list ap;
   va_start(ap, msg);
@@ -109,7 +109,7 @@ int gbser_setup(void* handle, const char* spec)
  */
 int gbser_avail(void* handle)
 {
-  return gbser__fill_buffer(handle, 1, nullptr);
+  return gbser_fill_buffer(handle, 1, nullptr);
 }
 
 /* Read as many bytes as are available without blocking. At most |len|
@@ -121,7 +121,7 @@ int gbser_read(void* handle, void* buf, unsigned len)
   int got = 0;
 
   while (len > 0) {
-    int rc = gbser__fill_buffer(handle, len, nullptr);
+    int rc = gbser_fill_buffer(handle, len, nullptr);
     if (rc < 0) {
       /* error */
       return rc;
@@ -129,7 +129,7 @@ int gbser_read(void* handle, void* buf, unsigned len)
       /* nothing available */
       break;
     }
-    got += gbser__read_buffer(handle, &buf, &len);
+    got += gbser_read_buffer(handle, &buf, &len);
   }
 
   return got;
@@ -144,10 +144,10 @@ int gbser_read_wait(void* handle, void* buf, unsigned len, unsigned ms)
 
   while (len > 0 && ms != 0) {
     int rc;
-    if (rc = gbser__fill_buffer(handle, len, &ms), rc < 0) {
+    if (rc = gbser_fill_buffer(handle, len, &ms), rc < 0) {
       return rc;
     }
-    got += gbser__read_buffer(handle, &buf, &len);
+    got += gbser_read_buffer(handle, &buf, &len);
   }
 
   return got;
diff --git a/gbser.h b/gbser.h
index 46f4647e50c2dae6d4d00f9a91e934cd036bacc8..d6b332a5d176080650dc36fefdf7b007720627db 100644 (file)
--- a/gbser.h
+++ b/gbser.h
@@ -19,8 +19,8 @@
 
  */
 
-#ifndef __GBSER_H
-#define __GBSER_H
+#ifndef GBSER_H_INCLUDED_
+#define GBSER_H_INCLUDED_
 
 #include <cstddef> // for size_t
 
@@ -136,4 +136,4 @@ int gbser_is_serial(const char* port_name);
 const char* fix_win_serial_name_r(const char* comname, char* obuf, size_t len);
 const char* fix_win_serial_name(const char* comname);
 
-#endif /* GBSER_H */
+#endif /* GBSER_H_INCLUDED_ */
index a8b4f80dc9b2cacd353d6e0b94db6a6a56cdd75d..9cf9904e6c0761bdd5aefef991c69cc61a4ce9aa 100644 (file)
@@ -44,7 +44,7 @@ struct gbser_handle {
 };
 
 /* Wrapper to safely cast a void * into a gbser_handle */
-static gbser_handle* gbser__get_handle(void* p)
+static gbser_handle* gbser_get_handle(void* p)
 {
   auto* h = (gbser_handle*) p;
   assert(h->magic == MYMAGIC);
@@ -133,7 +133,7 @@ void* gbser_init(const char* port_name)
 {
   gbser_handle* h;
 
-  gbser__db(4, "gbser_init(\"%s\")\n", port_name);
+  gbser_db(4, "gbser_init(\"%s\")\n", port_name);
 
   h = (gbser_handle*) xcalloc(sizeof *h, 1);
   h->magic = MYMAGIC;
@@ -173,7 +173,7 @@ failed:
  */
 void gbser_deinit(void* handle)
 {
-  gbser_handle* h = gbser__get_handle(handle);
+  gbser_handle* h = gbser_get_handle(handle);
 
   tcsetattr(h->fd, TCSAFLUSH, &h->old_tio);
   close(h->fd);
@@ -183,7 +183,7 @@ void gbser_deinit(void* handle)
 
 int gbser_set_port(void* handle, unsigned speed, unsigned bits, unsigned parity, unsigned stop)
 {
-  gbser_handle* h = gbser__get_handle(handle);
+  gbser_handle* h = gbser_get_handle(handle);
   speed_t s;
 
   static unsigned bit_flags[] = {
@@ -251,9 +251,9 @@ int gbser_set_port(void* handle, unsigned speed, unsigned bits, unsigned parity,
   return tcsetattr(h->fd, TCSADRAIN, &h->new_tio) ? gbser_ERROR : gbser_OK;
 }
 
-unsigned gbser__read_buffer(void* handle, void** buf, unsigned* len)
+unsigned gbser_read_buffer(void* handle, void** buf, unsigned* len)
 {
-  gbser_handle* h = gbser__get_handle(handle);
+  gbser_handle* h = gbser_get_handle(handle);
   unsigned count = *len;
   auto* cp = (unsigned char*) *buf;
   if (count > h->inbuf_used) {
@@ -276,10 +276,10 @@ unsigned gbser__read_buffer(void* handle, void** buf, unsigned* len)
  * be updated to indicate the remaining time on exit.
  * Returns the number of bytes available (>=0) or an error code (<0).
  */
-int gbser__fill_buffer(void* handle, unsigned want, unsigned* ms)
+int gbser_fill_buffer(void* handle, unsigned want, unsigned* ms)
 {
   int rc;
-  gbser_handle* h = gbser__get_handle(handle);
+  gbser_handle* h = gbser_get_handle(handle);
 
   if (want > BUFSIZE) {
     want = BUFSIZE;
@@ -362,7 +362,7 @@ int gbser__fill_buffer(void* handle, unsigned want, unsigned* ms)
  */
 int gbser_flush(void* handle)
 {
-  gbser_handle* h = gbser__get_handle(handle);
+  gbser_handle* h = gbser_get_handle(handle);
   h->inbuf_used = 0;
   if (tcflush(h->fd, TCIFLUSH)) {
     return gbser_ERROR;
@@ -375,7 +375,7 @@ int gbser_flush(void* handle)
  */
 int gbser_write(void* handle, const void* buf, unsigned len)
 {
-  gbser_handle* h = gbser__get_handle(handle);
+  gbser_handle* h = gbser_get_handle(handle);
   const char* bp = (const char*) buf;
   int rc;
   while (len > 0) {
@@ -402,7 +402,7 @@ int gbser_is_serial(const char* port_name)
   int is_port = 0;
 
   if (fd = open(port_name, O_RDWR | O_NOCTTY), fd == -1) {
-    gbser__db(1, "Failed to open port (%s) to check its type\n", strerror(errno));
+    gbser_db(1, "Failed to open port (%s) to check its type\n", strerror(errno));
     return 0;
   }
 
index 4c6a35abb238fff23873f6a0856516f637d0f51b..37c889eec7e7435573f1526a62eb75fb3696e20d 100644 (file)
@@ -22,6 +22,6 @@
 #define MYMAGIC 0x91827364
 #define BUFSIZE 512
 
-void gbser__db(int l, const char* msg, ...);
-int gbser__fill_buffer(void* h, unsigned want, unsigned* ms);
-unsigned gbser__read_buffer(void* handle, void** buf, unsigned* len);
+void gbser_db(int l, const char* msg, ...);
+int gbser_fill_buffer(void* h, unsigned want, unsigned* ms);
+unsigned gbser_read_buffer(void* handle, void** buf, unsigned* len);
index f47ea88c3d0132ad491a287f3dde259385f0ed02..3a19406a243d458371e7e145966d7af3076b1469 100644 (file)
@@ -42,7 +42,7 @@ struct gbser_handle {
 #define DEV_PREFIX "\\\\.\\\\"
 
 /* Wrapper to safely cast a void * into a gbser_handle */
-static gbser_handle* gbser__get_handle(void* p)
+static gbser_handle* gbser_get_handle(void* p)
 {
   gbser_handle* h = (gbser_handle*) p;
   assert(h->magic == MYMAGIC);
@@ -182,7 +182,7 @@ void* gbser_init(const char* port_name)
   gbser_handle* h = (gbser_handle*) xcalloc(1, sizeof(*h));
   const char* xname = fix_win_serial_name(port_name);
 
-  gbser__db(2, "Translated port name: \"%s\"\n", xname);
+  gbser_db(2, "Translated port name: \"%s\"\n", xname);
 
   h->magic = MYMAGIC;
 
@@ -214,7 +214,7 @@ failed:
  */
 void gbser_deinit(void* handle)
 {
-  gbser_handle* h = gbser__get_handle(handle);
+  gbser_handle* h = gbser_get_handle(handle);
 
   CloseHandle(h->comport);
 
@@ -223,7 +223,7 @@ void gbser_deinit(void* handle)
 
 int gbser_set_port(void* handle, unsigned speed, unsigned bits, unsigned parity, unsigned stop)
 {
-  gbser_handle* h = gbser__get_handle(handle);
+  gbser_handle* h = gbser_get_handle(handle);
   DCB tio;
 
   if (bits < 5 || bits > 8) {
@@ -266,9 +266,9 @@ int gbser_set_port(void* handle, unsigned speed, unsigned bits, unsigned parity,
   return gbser_OK;
 }
 
-unsigned gbser__read_buffer(void* handle, void** buf, unsigned* len)
+unsigned gbser_read_buffer(void* handle, void** buf, unsigned* len)
 {
-  gbser_handle* h = gbser__get_handle(handle);
+  gbser_handle* h = gbser_get_handle(handle);
   unsigned count = *len;
   unsigned char* cp = (unsigned char*) *buf;
   if (count > h->inbuf_used) {
@@ -291,10 +291,10 @@ unsigned gbser__read_buffer(void* handle, void** buf, unsigned* len)
  * be updated to indicate the remaining time on exit.
  * Returns the number of bytes available (>=0) or an error code (<0).
  */
-int gbser__fill_buffer(void* handle, unsigned want, unsigned* ms)
+int gbser_fill_buffer(void* handle, unsigned want, unsigned* ms)
 {
   int rc;
-  gbser_handle* h = gbser__get_handle(handle);
+  gbser_handle* h = gbser_get_handle(handle);
 
   if (want > BUFSIZE) {
     want = BUFSIZE;
@@ -353,7 +353,7 @@ int gbser__fill_buffer(void* handle, unsigned want, unsigned* ms)
  */
 int gbser_flush(void* handle)
 {
-  gbser_handle* h = gbser__get_handle(handle);
+  gbser_handle* h = gbser_get_handle(handle);
   h->inbuf_used = 0;
   if (!PurgeComm(h->comport, PURGE_RXCLEAR)) {
     return gbser_ERROR;
@@ -365,7 +365,7 @@ int gbser_flush(void* handle)
  */
 int gbser_write(void* handle, const void* buf, unsigned len)
 {
-  gbser_handle* h = gbser__get_handle(handle);
+  gbser_handle* h = gbser_get_handle(handle);
   DWORD nwritten;
   const char* bp = (const char*) buf;
   /* Not sure we need to spin here - but this'll work even if we don't */
index bc9164b38cf389235c2b6c32ce54cffe5629c6b7..7efd06ed8b53612205b47d1d1cc3d4b22d580289 100644 (file)
  * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 
+#include <array>                   // for array
+#include <cctype>                  // for isprint
+#include <cstdarg>                 // for va_end, va_list, va_start
+#include <cstdio>                  // for size_t, sprintf, fread, fclose, feof
+#include <cstdint>                 // for uint32_t, int32_t, int16_t, uint16_t
+#include <cstdlib>                 // for strtod, strtoul
+#include <cstring>                 // for strlen, memcmp, memcpy
+#include <ctime>                   // for time_t, tm
+
+#include <QByteArray>              // for QByteArray
+#include <QIntegerForSize>         // for qPrintable
+#include <QString>                 // for QString
+#include <QVector>                 // for QVector
+
 #include "defs.h"
-#include "gbser.h"
-#include "grtcirc.h"
-#include <cstdio>
-#include <cstdlib>
+#include "gbser.h"                 // for gbser_set_port, gbser_deinit, gbse...
+
 
 #define MYNAME      "WBT-100/200"
 #define NL          "\x0D\x0A"
@@ -499,17 +511,20 @@ static double get_param_float(const char* cmd)
 }
 
 /* Decompose binary date into discreet fields */
-#define _SPLIT_DATE(tim) \
-    int sec    = (((tim) >>  0) & 0x3F); \
-    int min    = (((tim) >>  6) & 0x3F); \
-    int hour   = (((tim) >> 12) & 0x1F); \
-    int mday   = (((tim) >> 17) & 0x1F); \
-    int mon    = (((tim) >> 22) & 0x0F); \
-    int year   = (((tim) >> 26) & 0x3F);
+std::array<int, 6> split_date(uint32_t tim)
+{
+  int sec    = (((tim) >>  0) & 0x3F);
+  int min    = (((tim) >>  6) & 0x3F);
+  int hour   = (((tim) >> 12) & 0x1F);
+  int mday   = (((tim) >> 17) & 0x1F);
+  int mon    = (((tim) >> 22) & 0x0F);
+  int year   = (((tim) >> 26) & 0x3F);
+  return {sec, min, hour, mday, mon, year};
+}
 
 static time_t decode_date(uint32_t tim)
 {
-  _SPLIT_DATE(tim)
+  auto [sec, min, hour, mday, mon, year] = split_date(tim);
   struct tm t;
 
   t.tm_sec    = sec;
@@ -524,7 +539,7 @@ static time_t decode_date(uint32_t tim)
 
 static int check_date(uint32_t tim)
 {
-  _SPLIT_DATE(tim)
+  auto [sec, min, hour, mday, mon, year] = split_date(tim);
 
   /* Sanity check the date. We don't allow years prior to 2004 because zero in
   * those bits will usually indicate that we have an altitude instead of a